package myjava.overloading;

public class Root2 {

   public static void main(String[] args) {

       Animal a = new Animal();
       Horse h = new Horse();
       Animal ah = new Horse();

       a.eat();
       h.eat();
       h.eat("carota");
       ah.eat();
   }
}

/* un metodo puo' essere sia overridato che overloadato */

class Animal {

   public void eat() {
      System.out.println("animal is eating");
   }
}

class Horse extends Animal {

   @Override
   public void eat() {
      System.out.println("horse is eating");
   }

   public void eat(String food) {
      System.out.println("horse is eating " + food);
   }
}
